from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.pool import SingletonThreadPool

engine = create_engine("sqlite:///file.db",
                        echo=False,
                        poolclass=SingletonThreadPool,
                        pool_size=5,
                        pool_recycle=7200,
                        connect_args={'check_same_thread': False})

metadata = MetaData(engine)

def get_conn():
    session_factory = sessionmaker(bind=engine)
    Session = scoped_session(session_factory)
    return Session

class ImageTable(object):
    image_tb = Table("image_tb", metadata, autoload=True)

